package cn.sczhyt.modules.szhy.controller;

import java.util.Arrays;
import java.util.Map;

import cn.sczhyt.modules.szhy.entity.MeetingUserEntity;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.sczhyt.modules.szhy.entity.MeetingSignInEntity;
import cn.sczhyt.modules.szhy.service.MeetingSignInService;
import cn.sczhyt.common.utils.PageUtils;
import cn.sczhyt.common.utils.R;



/**
 *
 *
 * @author luoshijie
 * @email 1169414426@qq.com
 * @date 2020-11-25 10:54:22
 */
@Api(tags = "PC端会议签到")
@RestController
@RequestMapping("szhy/meetingsignin")
public class MeetingSignInController {
    @Autowired
    private MeetingSignInService meetingSignInService;

    /**
     * 会议签到列表
     */
    @ApiOperation("PC查看会议签到列表")
    @RequestMapping("/list")
    public R list(@RequestParam String meetingId,
                  @RequestParam(defaultValue = "1") Integer page,
                  @RequestParam(defaultValue = "1000") Integer limit){

        IPage<MeetingSignInEntity> iPage = meetingSignInService.listByMeetingId(meetingId, page, limit);

        PageUtils list = new PageUtils(iPage);

        return R.ok().put("page", list);
    }


    /**
     * 会议未签到列表
     */
    @ApiOperation("PC查看会议签到列表")
    @RequestMapping("/list/notsignin")
    public R listNotSignIn(@RequestParam String meetingId,
                  @RequestParam(defaultValue = "1") Integer page,
                  @RequestParam(defaultValue = "1000") Integer limit){

        IPage<MeetingUserEntity> iPage = meetingSignInService.listNotSignInByMeetingId(meetingId, page, limit);

        PageUtils list = new PageUtils(iPage);

        return R.ok().put("page", list);
    }



    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("szhy:meetingsignin:info")
    public R info(@PathVariable("id") String id){
		MeetingSignInEntity meetingSignIn = meetingSignInService.getById(id);

        return R.ok().put("meetingSignIn", meetingSignIn);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("szhy:meetingsignin:save")
    public R save(@RequestBody MeetingSignInEntity meetingSignIn){
		meetingSignInService.save(meetingSignIn);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("szhy:meetingsignin:update")
    public R update(@RequestBody MeetingSignInEntity meetingSignIn){
		meetingSignInService.updateById(meetingSignIn);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("szhy:meetingsignin:delete")
    public R delete(@RequestBody String[] ids){
		meetingSignInService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
